<template>
  <div>
    <router-link to="/">
      <button>跳转到Home</button>
    </router-link>
    <input type="text" v-model="msg" placeholder="请输入" />
    <button @click="btnClick">提交</button>
  </div>
</template>
<script>
import create from "@/utils/create";
import Notice from "@/components/Notice/index";
export default {
  name: "Notice",
  data() {
    return {
      msg: "",
      notice: null,
    };
  },
  destroyed() {
    if(this.notice) {
      this.notice.hide();
    }
  },
  methods: {
    btnClick() {
      // 创建弹窗实例
      this.notice = create(Notice, {
        title: "这是弹窗标题",
        message: this.msg ? "登录！！！" : "有错！！！",
        duration: 12000,
      });
      this.notice.show();
    },
  },
};
</script>